package dao;

import dao.impl.HSQLDBDAOFactory;
import org.apache.log4j.*;
import java.sql.*;

public abstract class IDAO {
    private final static Logger Logs = Logger.getLogger(IDAO.class);
    public void delete(long id) {
        Connection connection = HSQLDBDAOFactory.getConnection();
        try {
            String deleteStatement = "DELETE FROM " + getTableName() + " WHERE id = ?";
            PreparedStatement statement = connection.prepareStatement(deleteStatement);
            statement.setLong(1, id);
            statement.executeUpdate();
        } catch(SQLException e) {
            Logs.info("Ошибка удаления" + e);
        }
    }

    protected abstract String getTableName();
}
